﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;

namespace calculator
{
    [TestFixture]
    class BinaryStringTester
    {
        [Test]
        public void getSimpleBinaryTest()
        {
            BinaryString bin = new BinaryString();
            Assert.AreEqual("10", bin.getBinaryString(2));//Changing 2 to it's binary form
        }
        
        [Test]
        public void addTrailingZerosTets()
        {
            BinaryString bin = new BinaryString();
            Assert.AreEqual("010", bin.addTrailingZeros(3, 2));//Adding one 0 to the start
        }
        
        [Test]
        public void flipingBitsInBinaryString()
        {
            BinaryString bin = new BinaryString();
            Assert.AreEqual("011",bin.flipBits("100"));//Flips the individual bits of a binary string representation of an integer number and returns it.    
        }

        [Test]
        public void testForNegativeNumber()
        {
            BinaryString bin = new BinaryString();
            try
            {
                bin.getBinaryString(-3);
                Assert.Fail();
            }
            catch (ArgumentException)
            {
                //The test was a success
            }
        }

        [Test]
        public void testForNullString()
        {
            BinaryString bin = new BinaryString();
            try
            {
                bin.flipBits(null);
                Assert.Fail();
            }
            catch (ArgumentNullException)
            {
                //The test was a success
            }
        }

        [Test]
        public void testForEmptyString()
        {
            BinaryString bin = new BinaryString();
            try
            {
                bin.flipBits("");
                Assert.Fail();
            }
            catch (ArgumentException)
            {
                //The test was a success
            }
        }
    }
}
